/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package times.persistence.entities;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Administrator
 */
@Entity
@Table(name = "price_source_slaughter_header")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "PriceSourceSlaughterHeader.findAll", query = "SELECT p FROM PriceSourceSlaughterHeader p"),
    @NamedQuery(name = "PriceSourceSlaughterHeader.findById", query = "SELECT p FROM PriceSourceSlaughterHeader p WHERE p.id = :id"),
    @NamedQuery(name = "PriceSourceSlaughterHeader.findByDate", query = "SELECT p FROM PriceSourceSlaughterHeader p WHERE p.date = :date"),
    @NamedQuery(name = "PriceSourceSlaughterHeader.findByWeek", query = "SELECT p FROM PriceSourceSlaughterHeader p WHERE p.week = :week"),
    @NamedQuery(name = "PriceSourceSlaughterHeader.findByProtokolo", query = "SELECT p FROM PriceSourceSlaughterHeader p WHERE p.protokolo = :protokolo")})
public class PriceSourceSlaughterHeader implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Basic(optional = false)
    @Column(name = "date")
    @Temporal(TemporalType.DATE)
    private Date date;
    @Basic(optional = false)
    @Column(name = "week")
    private String week;
    @Basic(optional = false)
    @Column(name = "protokolo")
    private String protokolo;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "priceSourceSlaughterHeaderId")
    private List<PriceSlaughterLamb> priceSlaughterLambList;
    @JoinColumn(name = "price_source_id", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private PriceSource priceSourceId;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "priceSourceSlaughterHeaderId")
    private List<PriceSlaughter> priceSlaughterList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "priceSourceSlaughterHeaderId")
    private List<SlaughterProperty> slaughterPropertyList;

    public PriceSourceSlaughterHeader() {
    }

    public PriceSourceSlaughterHeader(Integer id) {
        this.id = id;
    }

    public PriceSourceSlaughterHeader(Integer id, Date date, String week, String protokolo) {
        this.id = id;
        this.date = date;
        this.week = week;
        this.protokolo = protokolo;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }

    public String getWeek() {
        return week;
    }

    public void setWeek(String week) {
        this.week = week;
    }

    public String getProtokolo() {
        return protokolo;
    }

    public void setProtokolo(String protokolo) {
        this.protokolo = protokolo;
    }

    @XmlTransient
    public List<PriceSlaughterLamb> getPriceSlaughterLambList() {
        return priceSlaughterLambList;
    }

    public void setPriceSlaughterLambList(List<PriceSlaughterLamb> priceSlaughterLambList) {
        this.priceSlaughterLambList = priceSlaughterLambList;
    }

    public PriceSource getPriceSourceId() {
        return priceSourceId;
    }

    public void setPriceSourceId(PriceSource priceSourceId) {
        this.priceSourceId = priceSourceId;
    }

    @XmlTransient
    public List<PriceSlaughter> getPriceSlaughterList() {
        return priceSlaughterList;
    }

    public void setPriceSlaughterList(List<PriceSlaughter> priceSlaughterList) {
        this.priceSlaughterList = priceSlaughterList;
    }

    @XmlTransient
    public List<SlaughterProperty> getSlaughterPropertyList() {
        return slaughterPropertyList;
    }

    public void setSlaughterPropertyList(List<SlaughterProperty> slaughterPropertyList) {
        this.slaughterPropertyList = slaughterPropertyList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof PriceSourceSlaughterHeader)) {
            return false;
        }
        PriceSourceSlaughterHeader other = (PriceSourceSlaughterHeader) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return date + " - " + week + " - " + protokolo;
    }
    
}
